<?php
/**
 * @name SampleModel
 * @desc sample数据获取类, 可以访问数据库，文件，其它系统等
 * @author root
 */
class AddressModel
{
    public function __construct()
    {
        $this->db = Yaf_Registry::get('db');
        $this->time = date("Y-m-d H:i:s",time());
    }

    public function selectAddress($start,$everyPage)
    {
        $sql = "select * from `collection_sites` limit {$start},{$everyPage}";
        return $this->db->query($sql);
    }

    public function getAddressInfo($start,$everyPage)
    {
        $sql = "select * from `collection_sites` ";
        return $this->db->query($sql);
    }

    public function getAllCount()
    {
        $sql="select count(*) as `rows` from `collection_sites` ";
        return $this->db->query($sql);
    }

    public function add($info)
    {
        $sql="insert into collection_sites(`web`,`url`,`remark`) values('{$info['name']}','{$info['url']}','{$info['remark']}')";
        return $this->db->query($sql);
    }

    public function del($id)
    {
        $sql = "delete from collection_sites where website_id='{$id}' ";
        return $this->db->query($sql);
    }

    public function edit($info, $id)
    {
        $sql = "update `collection_sites` set `web`='{$info['name']}',`url`='{$info['url']}',`remark`='{$info['remark']}' WHERE `website_id`='{$id}'";
        return $this->db->query($sql);
    }
}

